<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <ui:composition>
        <p:dialog header="Selecionar foto de Perfil" widgetVar="dlg2" modal="true" height="500" width="800" resizable="false">
            <h:form id="formFoto" enctype="multipart/form-data">
                <h:panelGrid border="0"  columns="1" cellspacing="5" style="margin-left: auto;" width="100%">
                    <p:panel>
                        <h:panelGrid columns="2" width="50%">
                            <p:commandButton value="Establecer como foto de perfil"
                                             disabled="#{usuarioController.imageTemp==null}"
                                             action="#{usuarioController.actionGuardarFoto}"
                                             process="@form"
                                          
                                             update="formFoto"/>
                            
                            <p:commandButton id="buttonFoto" value="Establecer Foto" actionListener="#{usuarioController.guardarFoto}"/>
                           
                            <p:commandButton value="Cancelar"
                                             type="button"
                                             onclick="PF('dlg2').hide();"/>
                        </h:panelGrid>
                    </p:panel>

                    <p:panel styleClass="editorFoto">
                        <p:imageCropper value="#{usuarioController.croppeFoto}"
                                        image="../../Documentos/temp/#{usuarioController.imageTemp}"
                                        rendered="#{usuarioController.imageTemp!=null}"
                                        initialCoords="0,0,140,150"
                                        minSize="70,75"
                                        maxSize="280,300"
                                        aspectRatio="0.9"/>

                        <p:fileUpload fileUploadListener="#{usuarioController.uploadFile}"
                                      rendered="#{usuarioController.imageTemp==null}"
                                      mode="advanced"
                                      label="Seleccione Foto"
                                      auto="true"
                                      update="formFoto"
                                      sizeLimit="500000"
                                      allowTypes="/(\.|\/)(gif|jpe?g|png)$/"/>
                    </p:panel>
                </h:panelGrid>
            </h:form>
        </p:dialog>
    </ui:composition>
</html>

